package com.ridvanari.myfirstandroidapp;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.media.MediaPlayer;
import android.net.Uri;

public class MyFirstAndroidAppActivity extends Activity {
    
	private static final String DEBUG_TAG= "MyFirstAppLogging";
	
	private MediaPlayer mp;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        //ForceError();
        this.PlayMusicFromWeb();
    }
    
    public void ForceError()
    {
    	if(true) {
			throw new Error("Upppsss..");
		}
    }
    
    public void PlayMusicFromWeb()
    {
    	try {
    		Uri file = Uri.parse("http://www.perlgurl.org/podcast/archives/podcasts/PerlgurlPromo.mp3");
			MediaPlayer.create(this, file);
			mp.start();
			
		} catch (Exception e) {
			Log.e(DEBUG_TAG,"Player Failed", e);
		}
    }

	@Override
	protected void onStop() {
		if(mp != null)
		{
			mp.stop();
			mp.release();
		}			
		super.onStop();
	}
}